package cn.ffcs.uec.outStaffEntryApply.action;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.SuspendNotAllowedException;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Window;

import cn.ffcs.raptornuke.plugin.common.zk.ctrl.BasePortletComposer;
import cn.ffcs.raptornuke.plugin.common.zk.util.ZkUtil;
import cn.ffcs.raptornuke.portal.theme.ThemeDisplay;
import cn.ffcs.uec.common.util.NodeVoUtil;
import cn.ffcs.uec.common.util.UecConstants;
import cn.ffcs.uec.organization.manager.UecOrgOrgsManager;
import cn.ffcs.uec.outStaff.constant.UecOutStaffConstants;
import cn.ffcs.uec.outStaff.manager.UecOutStaffManager;
import cn.ffcs.uec.outStaff.model.UecOutStaffInfo;
import cn.ffcs.uec.outStaffEntryApply.action.bean.OutStaffEntryApprovalViewMainBean;
import cn.ffcs.uec.recordsApproval.constant.ApprovalConstants;
import cn.ffcs.uec.recordsApproval.manager.ActRunTaskManager;
import cn.ffcs.uec.recordsApproval.util.ApprovalUtil;
import cn.ffcs.uec.staff.manager.UecTrialManager;
import cn.ffcs.uec.staff.model.UecTrial;
import cn.ffcs.uec.staffRecords.vo.AtiOaBaseObject;
import cn.ffcs.uom.common.model.DefaultDaoFactory;
import cn.ffcs.uom.common.util.ApplicationContextUtil;
import cn.ffcs.uom.common.util.DateUtil;
import cn.ffcs.uom.common.util.ListboxUtils;
import cn.ffcs.uom.common.util.PlatformUtil;
import cn.ffcs.uom.common.util.PubUtil;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.vo.NodeVo;

/**
 * 外包人员入职审批弹框Composer
 * 
 * @author liuxiaodong
 *
 */
@Controller
@Scope("prototype")
public class OutStaffEntryApprovalViewMainComposer extends BasePortletComposer {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6410906401618060829L;

	private OutStaffEntryApprovalViewMainBean bean = new OutStaffEntryApprovalViewMainBean();

	private UecTrialManager uecTrialManager = (UecTrialManager) ApplicationContextUtil
			.getBean("uecTrialManager");

	private static UecOutStaffManager uecOutStaffManager = (UecOutStaffManager) ApplicationContextUtil
			.getBean("uecOutStaffManager");

	private UecOrgOrgsManager uecOrgOrgsManager = (UecOrgOrgsManager) ApplicationContextUtil
			.getBean("uecOrgOrgsManager");

	private ActRunTaskManager actRunTaskManager = (ActRunTaskManager) ApplicationContextUtil
			.getBean("actRunTaskManager");

	private UecOutStaffInfo outStaffInfo = UecOutStaffInfo.newInstance();

	private UecTrial trial = UecTrial.newInstance();

	private String taskDefKey;

	/**
	 * 操作类型 查看 、非查看
	 */
	private String type;

	private String taskId;

	private AtiOaBaseObject oaBaseObject;

	@Override
	public String getPortletId() {
		return super.getPortletId();
	}

	@Override
	public ThemeDisplay getThemeDisplay() {
		return super.getThemeDisplay();
	}

	public void doAfterCompose(Component comp) throws Exception {
		super.doAfterCompose(comp);
		Components.wireVariables(comp, bean);
	}

	/**
	 * 界面初始化
	 */
	public void onCreate$outStaffEntryApprovalViewMainWin() {
		// this.bean.getGroupboxB().setVisible(false);
		bindCombobox();
		bindBean();
	}

	/**
	 * 查看綁定的各Tab页
	 * 
	 * @throws InterruptedException
	 * @throws SuspendNotAllowedException
	 */
	public void onStaffView() throws SuspendNotAllowedException,
			InterruptedException {
		if (!StrUtil.isNullOrEmpty(outStaffInfo.getOutStaffId())) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("oaBaseObject", oaBaseObject);
			map.put("taskDefKey", taskDefKey);

			Window window = (Window) Executions
					.createComponents(
							UecOutStaffConstants.UEC_OUT_STAFF_ENTRY_TABS_APPROVAL_VIEW_EDIT_ZUL,
							null, map);
			window.doModal();
			window.addEventListener("onOK", new EventListener() {
				@Override
				public void onEvent(Event event) throws Exception {
					// do Noting
				}
			});
		}

	}

	/**
	 * 重新申请
	 * 
	 * @throws InterruptedException
	 */
	public void onOk() throws InterruptedException {

		if (!"onView".equals(type)) {
			// 判断任务是否已被处理
			boolean isCompleted = ApprovalUtil.isTaskCompleted(oaBaseObject,
					taskId);
			if (isCompleted) {
				onCancel();
				Events.postEvent(ApprovalConstants.ON_REFRESH_QUERY_RESPONSE,
						this.self, null);
				ZkUtil.showError("任务不存在或已被处理完毕！", "错误提示");
				return;
			}
			// 入职前字段校验
			String msg = this.checkUacStaffData();
			if (null != msg) {
				Messagebox.show(msg);
				return;
			}
			Messagebox.show("是否提交审批？", "输入确认提示", Messagebox.OK
					| Messagebox.CANCEL, Messagebox.QUESTION,
					new EventListener() {
						@Override
						public void onEvent(Event event) throws Exception {
							if (((Integer) event.getData()).intValue() == Messagebox.OK) {
								postApprovalData();
								onCancel();
							} else {
								return;
							}
						}
					});

		} else {
			this.onCancel();
		}

	}

	/**
	 * 提交审批数据
	 * 
	 * @throws InterruptedException
	 */
	public void postApprovalData() throws InterruptedException {
		// 获取登录用户
		String currentName = "";
		if (StrUtil.isNullOrEmpty(PlatformUtil.getCurrentUser())) {
			ZkUtil.showError("当前登录用户已经失效，请重新登录系统", "错误提示");
			return;
		} else {
			currentName = PlatformUtil.getCurrentUser().getScreenName();
		}
		PubUtil.fillPoFromBean(bean, outStaffInfo);
		outStaffInfo.setJoinWorkDate(DateUtil.dateToStr(bean.getJoinWorkDate()
				.getValue()));
		outStaffInfo.setGlbdef3(DateUtil
				.dateToStr(bean.getGlbdef3().getValue()));
		outStaffInfo.setEnterUnitTime(DateUtil.dateToStr(bean
				.getEnterUnitTime().getValue()));
		outStaffInfo.setModifier(currentName);
		outStaffInfo.setModifiedTime(DateUtil.getCurrenDate());

		DefaultDaoFactory.getDefaultDao().updateObject(outStaffInfo);

		PubUtil.fillPoFromBean(bean, trial);
		// 获取试用类型
		Object value = bean.getTrialType().getSelectedItem().getValue();
		Long trialType = Long.valueOf(String.valueOf(value));
		trial.setTrialType(trialType);
		// 获取试用开始日期
		trial.setBegindate(DateUtil.dateToStr(bean.getBegindate().getValue()));
		// 获取试用结束日期
		trial.setEnddate(DateUtil.dateToStr(bean.getEnddate().getValue()));
		trial.setModifier(currentName);
		trial.setModifiedtime(DateUtil.getCurrenDate());
		DefaultDaoFactory.getDefaultDao().updateObject(trial);

		Events.postEvent("onOKResponse", this.self,
				ApprovalConstants.ON_OK_RESULT);
	}

	/**
	 * 审批同意
	 * 
	 * @throws InterruptedException
	 */
	public void onApproval() throws InterruptedException {
		Messagebox.show("是否提交审批？", "输入确认提示", Messagebox.OK | Messagebox.CANCEL,
				Messagebox.QUESTION, new EventListener() {
					@Override
					public void onEvent(Event event) throws Exception {
						if (((Integer) event.getData()).intValue() == Messagebox.OK) {
							approvalData();
						} else {
							return;
						}
					}
				});
	}

	/**
	 * 审批数据
	 */
	public void approvalData() {
		Map<String, Object> map = new HashMap<String, Object>();
		String comment = this.getComment(taskDefKey);
		map.put("comment", comment);
		map.put("onApprovalResult", ApprovalConstants.ON_APPROVAL_RESULT);
		Events.postEvent("onApprovalResponse", this.self, map);
		this.onCancel();
	}

	/**
	 * 审批拒绝
	 */
	public void onReject() {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("comment", this.getComment(taskDefKey));
		map.put("onRejectResult", ApprovalConstants.ON_REJECT_RESULT);
		Events.postEvent("onRejectResponse", this.self, map);
		this.onCancel();
	}

	/**
	 * 关闭窗口
	 */
	public void onCancel() {
		this.bean.getOutStaffEntryApprovalViewMainWin().onClose();
	}

	/**
	 * 获取传值
	 * 
	 * @throws ParseException
	 * @throws WrongValueException
	 */
	private void bindBean() {
		
		/*
		 * String procDefName = (String) arg.get("procDefName");
		 * this.bean.getOutStaffEntryApprovalViewMainWin().setTitle( procDefName
		 * + "审批");
		 */
		oaBaseObject = (AtiOaBaseObject) arg.get("oaBaseObject");
		if (!StrUtil.isNullOrEmpty(oaBaseObject)) {
			// 获取审批意见
			PubUtil.fillBeanFromPo(oaBaseObject, bean);
		}

		type = (String) arg.get("opType");
		if ("onView".equals(type)) {
			// 查看历史工单
			setButtonValid(true, false, false);
			setTextValid(true, true, true);
		} else {
			// 审批中弹框
			taskDefKey = (String) arg.get("taskDefKey");
			if ("modify".equals(taskDefKey)) {
				setButtonValid(true, false, false);
				setTextValid(false, false, false);
			} else {
				setButtonValid(false, true, true);
			}
			if ("deptLeaderAudit".equals(taskDefKey)) {
				this.bean.getSecondText().setRows(2);
				this.setTextValid(true, false, false);
				bean.getSecondText().setValue(null);
			}
			if ("hrAudit".equals(taskDefKey)) {
				this.bean.getThirdText().setRows(2);
				this.setTextValid(false, true, false);
				bean.getThirdText().setValue(null);
			}
			if ("hrLeaderAudit".equals(taskDefKey)) {
				this.bean.getFourthText().setRows(2);
				this.setTextValid(false, false, true);
				bean.getFourthText().setValue(null);
			}
		}
		
		taskId = (String) arg.get("taskId");
		if (!StrUtil.isNullOrEmpty(oaBaseObject)) {

			List<Map<String, Object>> list = actRunTaskManager
					.getRuTasks(oaBaseObject.getProcInstId());
			if (null == list) {
				ZkUtil.showError("未知错误!", "错误信息");
				return;
			}
			if (list.size() == 0) {
				String outStaffIdTmp = oaBaseObject.getOutStaffId();
				oaBaseObject.setOutStaffId(oaBaseObject.getOutStaffIdHis());
				oaBaseObject.setOutStaffIdHis(outStaffIdTmp);
			}

			// UecOrgOrgs newOrgOrgs = UecOrgOrgs.newInstance();
			// 获取原数据
			// String outStaffIdHis = oaBaseObject.getOutStaffIdHis();
			// if (!StrUtil.isNullOrEmpty(outStaffIdHis)) {
			// outStaffInfo = UecOutStaffInfo.newInstance();
			// outStaffInfo.setOutStaffId(Long.parseLong(outStaffIdHis));
			// outStaffInfo = uecOutStaffManager
			// .findUecOutStaffInfoByOutStaffId(outStaffInfo);
			// if (null != outStaffInfo) {
			// newOrgOrgs.setPkOrg(outStaffInfo.getPkHrorg());
			// newOrgOrgs = uecOrgOrgsManager
			// .findUecOrgOrgsByUecOrgOrgs(newOrgOrgs);
			// if (null != newOrgOrgs) {
			// bean.getUecOrgOrgsBandboxExtHis().setValue(
			// newOrgOrgs.getName());
			// }
			// 人员属性
			// @SuppressWarnings("unchecked")
			// List<Listitem> propertyItems = bean.getProperty().getChildren();
			// for (Listitem listitem : propertyItems) {
			// if (null != listitem && null != listitem.getValue()) {
			// if (listitem.getValue().toString()
			// .equals(outStaffInfo.getProperty())) {
			// bean.getProperty().setSelectedItem(listitem);
			// break;
			// }
			// }
			// }
			// bean.getJoinWorkDateHis().setValue(
			// outStaffInfo.getJoinWorkDate());
			// bean.getJoinPolityDateHis().setValue(
			// outStaffInfo.getJoinPolityDate());
			// bean.getGlbdef3His().setValue(outStaffInfo.getGlbdef3());
			// bean.getEnterUnitTimeHis().setValue(
			// outStaffInfo.getEnterUnitTime());
			// 绑定政治面貌
			// @SuppressWarnings("unchecked")
			// List<Listitem> polityItemList = bean.getPolityHis()
			// .getChildren();
			// for (Listitem listitem : polityItemList) {
			// if (null != listitem && null != listitem.getValue()) {
			// if (listitem.getValue().toString()
			// .equals(outStaffInfo.getPolity())) {
			// bean.getPolityHis().setSelectedItem(listitem);
			// break;
			// }
			// }
			// }
			// bean.getProfHis().setValue(outStaffInfo.getProf());
			// bean.getTitleTechpostHis().setValue(
			// outStaffInfo.getTitleTechpost());
			// 进入电信系统来源
			// @SuppressWarnings("unchecked")
			// List<Listitem> items = bean.getGlbdef2His().getChildren();
			// for (Listitem listitem : items) {
			// if (null != listitem && null != listitem.getValue()) {
			// if (listitem.getValue().toString()
			// .equals(outStaffInfo.getGlbdef2())) {
			// bean.getGlbdef2His().setSelectedItem(listitem);
			// break;
			// }
			// }
			// }
			// 是否门店营业员
			// @SuppressWarnings("unchecked")
			// List<Listitem> itemsIsshopassistHis = bean
			// .getIsshopassistHis().getChildren();
			// for (Listitem listitem : itemsIsshopassistHis) {
			// if (null != listitem && null != listitem.getValue()) {
			// if (listitem.getValue().toString()
			// .equals(outStaffInfo.getIsshopassist())) {
			// bean.getIsshopassistHis().setSelectedItem(
			// listitem);
			// break;
			// }
			// }
			// }
			// 启用状态
			// @SuppressWarnings("unchecked")
			// List<Listitem> itemsEnableStateHis = bean
			// .getEnableStateHis().getChildren();
			// for (Listitem listitem : itemsEnableStateHis) {
			// if (null != listitem && null != listitem.getValue()) {
			// if (listitem
			// .getValue()
			// .toString()
			// .equals(String.valueOf(outStaffInfo
			// .getEnableState()))) {
			// bean.getEnableStateHis().setSelectedItem(
			// listitem);
			// break;
			// }
			// }
			// }
			// 是否承包经营个体
			// @SuppressWarnings("unchecked")
			// List<Listitem> itemsGlbdef14His = bean.getGlbdef14His()
			// .getChildren();
			// for (Listitem listitem : itemsGlbdef14His) {
			// if (null != listitem && null != listitem.getValue()) {
			// if (listitem.getValue().toString()
			// .equals(outStaffInfo.getGlbdef14())) {
			// bean.getGlbdef14His().setSelectedItem(listitem);
			// break;
			// }
			// }
			// }
			// 是否历史成员
			// @SuppressWarnings("unchecked")
			// List<Listitem> itemsIshiskeypsnHis = bean
			// .getIshiskeypsnHis().getChildren();
			// for (Listitem listitem : itemsIshiskeypsnHis) {
			// if (null != listitem && null != listitem.getValue()) {
			// if (listitem.getValue().toString()
			// .equals(outStaffInfo.getIshiskeypsn())) {
			// bean.getIshiskeypsnHis().setSelectedItem(
			// listitem);
			// break;
			// }
			// }
			// }
			// bean.getHomePhoneHis()
			// .setValue(outStaffInfo.getHomePhone());
			// bean.getGlbdef8His().setValue(outStaffInfo.getGlbdef8());
			// }
			//
			// }

			String trialId = oaBaseObject.getTrialId();
			if (!StrUtil.isNullOrEmpty(trialId)) {
				// 获取审批状态试用信息
				trial.setTrialId(Long.parseLong(trialId));
				trial = uecTrialManager.findUecTrialById(trial);
				if (!StrUtil.isNullOrEmpty(trial)) {
					PubUtil.fillBeanFromPo(trial, bean);
					bean.getBegindate().setValue(
							DateUtil.patternStrToDate(trial.getBegindate()));
					bean.getEnddate().setValue(
							DateUtil.patternStrToDate(trial.getEnddate()));
				}

				// 获取审批状态人员基本信息
				outStaffInfo.setOutStaffId(Long.parseLong(oaBaseObject
						.getOutStaffId()));
				outStaffInfo = uecOutStaffManager
						.findUecOutStaffInfoByOutStaffId(outStaffInfo);
				PubUtil.fillBeanFromPo(outStaffInfo, bean);
				String orgName = uecOrgOrgsManager
						.getUecOrgOrgsNameByPkOrg(outStaffInfo.getPkHrorg());
				bean.getPkHrorgName().setValue(orgName);

				// 对页面上 fillBeanFromPo 不显示时间 作如下操作
				// 此时bean 中joinWorkDate的值格式为 Fri Jun 01 00:00:00 CST 2018

				bean.getJoinWorkDate().setValue(
						DateUtil.patternStrToDate(outStaffInfo
								.getJoinWorkDate()));
				// if (!StrUtil.isNullOrEmpty(outStaffInfo.getJoinPolityDate()))
				// {
				// bean.getJoinPolityDate().setValue(
				// DateUtil.patternStrToDate(outStaffInfo
				// .getJoinPolityDate()));
				// }
				bean.getGlbdef3().setValue(
						DateUtil.patternStrToDate(outStaffInfo.getGlbdef3()));
				bean.getEnterUnitTime().setValue(
						DateUtil.patternStrToDate(outStaffInfo
								.getEnterUnitTime()));

			}

		}
	}

	/**
	 * 获取审批意见
	 * 
	 * @param taskDefKey
	 * @return
	 */
	private String getComment(String taskDefKey) {
		if ("deptLeaderAudit".equals(taskDefKey)) {
			return this.bean.getSecondText().getValue();
		}
		if ("hrAudit".equals(taskDefKey)) {
			return this.bean.getThirdText().getValue();
		}
		if ("hrLeaderAudit".equals(taskDefKey)) {
			return this.bean.getFourthText().getValue();
		}
		return null;
	}

	/**
	 * 设置按钮
	 * 
	 * @param canEdit
	 * @param canApproval
	 * @param canReject
	 */
	private void setButtonValid(boolean canEdit, boolean canApproval,
			boolean canReject) {
		this.bean.getOkBtn().setVisible(canEdit);
		this.bean.getOkBtn().setDisabled(!canEdit);

		this.bean.getApprovalBtn().setVisible(canApproval);
		this.bean.getApprovalBtn().setDisabled(!canApproval);

		this.bean.getRejectBtn().setVisible(canReject);
		this.bean.getRejectBtn().setDisabled(!canReject);

	}

	/**
	 * 设置审批意见栏
	 * 
	 * @param secondCanEdit
	 * @param thirdCanEdit
	 * @param fourthCanEdit
	 */
	private void setTextValid(boolean secondCanEdit, boolean thirdCanEdit,
			boolean fourthCanEdit) {
		this.bean.getSecondText().setDisabled(!secondCanEdit);
		this.bean.getThirdText().setDisabled(!thirdCanEdit);
		this.bean.getFourthText().setDisabled(!fourthCanEdit);
	}

	/**
	 * 检测填入的参数是否为空
	 */
	public String checkUacStaffData() {
		if (StrUtil.isNullOrEmpty(bean.getProperty().getSelectedItem()
				.getValue())) {
			return "请选择外包人员属性";
		} else if (StrUtil.isNullOrEmpty(bean.getNationality()
				.getSelectedItem().getValue())) {
			return "请选择民族";
		} else if (StrUtil.isNullOrEmpty(bean.getJoinWorkDate().getValue())) {
			return "请选择参加工作日期";
		} else if (StrUtil.isNullOrEmpty(bean.getGlbdef3().getValue())) {
			return "请选择进入电信系统日期";
		} else if (StrUtil.isNullOrEmpty(bean.getEnterUnitTime().getValue())) {
			return "请选择进入本单位日期";
		} else if (StrUtil.isNullOrEmpty(bean.getGlbdef7().getValue())) {
			return "请填写紧急联系人姓名";
		} else if (StrUtil.isNullOrEmpty(bean.getCharacterrpr()
				.getSelectedItem().getValue())) {
			return "请选择户口性质";
		} else if (StrUtil.isNullOrEmpty(bean.getHomePhone().getValue())) {
			return "请输入家庭联系电话";
		} else if (StrUtil.isNullOrEmpty(bean.getHealth().getSelectedItem()
				.getValue())) {
			return "请选择健康状况";
		} else if (StrUtil.isNullOrEmpty(bean.getMarital().getSelectedItem()
				.getValue())) {
			return "请选择婚姻状况";
		} else if (StrUtil.isNullOrEmpty(bean.getGlbdef8().getValue())) {
			return "请输入紧急联系人手机";
		} else if (StrUtil.isNullOrEmpty(bean.getGlbdef2().getSelectedItem()
				.getValue())) {
			return "请选择进入电信系统来源";
		} else if (StrUtil.isNullOrEmpty(bean.getEmail().getValue())) {
			return "请输入电子邮件";
		} else if (StrUtil.isNullOrEmpty(bean.getCensusAddr().getValue())) {
			return "请填写户籍地址";
		} else if (StrUtil.isNullOrEmpty(bean.getFileAddress().getValue())) {
			return "请填写档案所在地";
		} else if (StrUtil.isNullOrEmpty(bean.getGlbdef13().getValue())) {
			return "请填写家庭地址";
		} else if (StrUtil.isNullOrEmpty(bean.getGlbdef12().getValue())) {
			return "请填写本人户口地址";
		} else if (StrUtil.isNullOrEmpty(bean.getTrialType().getSelectedItem()
				.getValue())) {
			return "请选择试用类型";
		} else if (StrUtil.isNullOrEmpty(bean.getBegindate().getValue())) {
			return "请选择试用开始日期";
		} else if (StrUtil.isNullOrEmpty(bean.getEnddate().getValue())) {
			return "请选择试用结束日期";
		}
		// 判断字符个数，并限制
		else if (bean.getUsedName().getValue().length() > UecOutStaffConstants.UEC_MAX_COUNT) {
			return "曾用名字符个数超出限制";
		} else if (bean.getGlbdef7().getValue().length() > UecOutStaffConstants.UEC_MAX_COUNT) {
			return "紧急联系人姓名字符个数超出限制";
		} else if (bean.getCensusAddr().getValue().length() > UecOutStaffConstants.UEC_MAX_COUNT) {
			return "户籍地址字符个数超出限制";
		} else if (bean.getFileAddress().getValue().length() > UecOutStaffConstants.UEC_MAX_COUNT) {
			return "档案所在地字符个数超出限制";
		} else if (bean.getGlbdef12().getValue().length() > UecOutStaffConstants.UEC_MAX_COUNT) {
			return "本人户口地址字符个数超出限制";
		} else if (bean.getGlbdef13().getValue().length() > UecOutStaffConstants.UEC_MAX_COUNT) {
			return "家庭地址字符个数超出限制";
		} else if (bean.getDieRemark().getValue().length() > UecOutStaffConstants.UEC_MAX_COUNT) {
			return "身故说明字符个数超出限制";
		} else if (bean.getMemo().getValue().length() > UecOutStaffConstants.UEC_MAX_COUNT) {
			return "备注字符个数超出限制";
		} else if (bean.getEmail().getValue().length() > UecOutStaffConstants.EMAIL_MAX_COUNT) {
			return "邮件字符个数超出限制";
		} else if (bean.getHomePhone().getValue().length() > UecOutStaffConstants.PHONE_MAX_COUNT) {
			return "家庭电话字符个数超出限制";
		} else if (bean.getGlbdef8().getValue().length() > UecOutStaffConstants.PHONE_MAX_COUNT) {
			return "紧急联系人电话字符个数超出限制";
		}
		return null;
	}

	/**
	 * 绑定下拉菜单
	 */
	private void bindCombobox() {

		// 健康状况
		ListboxUtils.rendererForEdit(bean.getHealth(),
				NodeVoUtil.getDictionaries(UecConstants.HELATH));
		// 绑定民族nationality
		ListboxUtils.rendererForEdit(bean.getNationality(),
				NodeVoUtil.getDictionaries(UecConstants.NATION));
		// 婚姻状况marital
		ListboxUtils.rendererForEdit(bean.getMarital(),
				NodeVoUtil.getDictionaries(UecConstants.MARRIAGE));
		// 政治面貌
		ListboxUtils.rendererForEdit(bean.getPolity(),
				NodeVoUtil.getDictionaries(UecConstants.POLITICAL_OUTLOOK));
		// 户口性质characterrpr
		ListboxUtils.rendererForEdit(bean.getCharacterrpr(),
				NodeVoUtil.getDictionaries(UecConstants.NATURE_REGISTRATION));
		// 进入电信系统来源--glbdef2
		ListboxUtils.rendererForEdit(bean.getGlbdef2(), NodeVoUtil
				.getDictionaries(UecConstants.ASSCESS_SOURCE_TELESTSTEM));

		/**
		 * 人员属性--property 0:合同制用工 1：派遣制用工 2：外包自有 3：外包其他
		 */
		// 人员属性
		List<NodeVo> nodeVoPropertyList = new ArrayList<NodeVo>();
		String[][] property = { { "2", "外包自有" }, { "3", "外包其他" } };
		for (int i = 0; i < property.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(property[i][j]);
				nodeVo.setName(property[i][j + 1]);
			}
			nodeVoPropertyList.add(nodeVo);
		}
		ListboxUtils.rendererForEdit(bean.getProperty(), nodeVoPropertyList);

		// 绑定启用状态
		List<NodeVo> nodeVoEnableStateList = new ArrayList<NodeVo>();
		String[][] enableState = { { "1", "未启用" }, { "2", "已启用" },
				{ "3", "已停用" } };
		for (int i = 0; i < enableState.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(enableState[i][j]);
				nodeVo.setName(enableState[i][j + 1]);
			}
			nodeVoEnableStateList.add(nodeVo);
		}
		ListboxUtils.rendererForEdit(bean.getEnableState(),
				nodeVoEnableStateList);

		// 是否是历史成员
		List<NodeVo> nodeVoIshiskeypsnList = new ArrayList<NodeVo>();
		String[][] ishiskeypsn = { { "Y", "是" }, { "N", "否" } };
		for (int i = 0; i < ishiskeypsn.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(ishiskeypsn[i][j]);
				nodeVo.setName(ishiskeypsn[i][j + 1]);
			}
			nodeVoIshiskeypsnList.add(nodeVo);
		}
		ListboxUtils.rendererForEdit(bean.getIshiskeypsn(),
				nodeVoIshiskeypsnList);
		// 是否是门店营业员
		ListboxUtils.rendererForEdit(bean.getIsshopassist(),
				nodeVoIshiskeypsnList);
		// 是否承包经营个人
		ListboxUtils.rendererForEdit(bean.getGlbdef14(), nodeVoIshiskeypsnList);

		/**
		 * 人员试用情况
		 */
		// 试用类型trialType
		List<NodeVo> nodeVoTrialTypeList = new ArrayList<NodeVo>();
		String[][] trialType = { { "1", "入职试用" }, { "2", "转岗试用" } };
		for (int i = 0; i < trialType.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(trialType[i][j]);
				nodeVo.setName(trialType[i][j + 1]);
			}
			nodeVoTrialTypeList.add(nodeVo);
		}
		ListboxUtils.rendererForEdit(bean.getTrialType(), nodeVoTrialTypeList);

		// 绑定启用状态
		List<NodeVo> nodeVoEnableStateListHis = new ArrayList<NodeVo>();
		String[][] enableStateHis = { { "1", "未启用" }, { "2", "已启用" },
				{ "3", "已停用" } };
		for (int i = 0; i < enableStateHis.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(enableStateHis[i][j]);
				nodeVo.setName(enableStateHis[i][j + 1]);
			}
			nodeVoEnableStateListHis.add(nodeVo);
		}
		ListboxUtils.rendererForEdit(bean.getEnableStateHis(),
				nodeVoEnableStateListHis);

		// 是否是历史成员
		List<NodeVo> nodeVoIshiskeypsnListHis = new ArrayList<NodeVo>();
		String[][] ishiskeypsnHis = { { "Y", "是" }, { "N", "否" } };
		for (int i = 0; i < ishiskeypsnHis.length; i++) {
			NodeVo nodeVo = new NodeVo();
			for (int j = 0; j < 1; j++) {
				nodeVo.setId(ishiskeypsnHis[i][j]);
				nodeVo.setName(ishiskeypsnHis[i][j + 1]);
			}
			nodeVoIshiskeypsnListHis.add(nodeVo);
		}
		ListboxUtils.rendererForEdit(bean.getIshiskeypsnHis(),
				nodeVoIshiskeypsnListHis);
		// 是否是门店营业员
		ListboxUtils.rendererForEdit(bean.getIsshopassistHis(),
				nodeVoIshiskeypsnListHis);
		// 是否承包经营个人
		ListboxUtils.rendererForEdit(bean.getGlbdef14His(),
				nodeVoIshiskeypsnListHis);
	}

}
